import axios from 'axios'
import store from '../store'
// import { getToken } from './auth'

const service = axios.create({
  baseURL: '/api',
  timeout: 5000
})

// request拦截器
service.interceptors.request.use(
  config => {
    if (store.getters.token) {
      config.headers['Authorization'] = store.getters.token // 让每个请求携带自定义token 请根据实际情况自行修改
    }
    return config
  },
  error => {
    // Do something with request error
    console.log(error) // for debug
    Promise.reject(error)
  }
)

export default service
